<?php
class Article extends Home_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->Model(array("Mpages"));
	}	
	
	public function index(){
		set_time_limit(0);
		$url = $this->uri->segment(2);
		$langCode = $this->session->userdata('current_language');
		$dataPage = $this->Mpages->getDataPages($url, $langCode['code']);
		if(count($dataPage) != 0){
			$encry = md5(base64_encode($dataPage['page_url'].$dataPage['page_id']));
			if(!$this->cache->get($encry)){
				$data['template'] = 'home/article/index';
				$data['titlePage'] = $dataPage['page_name'];
				$data['keywordsPage'] = $dataPage['page_key'];
				$data['descriptionPage'] = $dataPage['page_description'];
				$data['backgroundPage'] = $dataPage['background'];
				$data['activeGallery'] = $dataPage['active_gallery'];
				$data['imagesPage'] = $dataPage['images'];
				$data['titleArticle'] = $dataPage['art_title'];
				$data['titleArticle2'] = $dataPage['art_title_2'];
				$data['titleArticle3'] = $dataPage['art_title_3'];
				$data['contentArticle'] = $dataPage['art_content'];
				$data['subArticle'] = $this->Mpages->getSubArticle($dataPage['art_id'], $langCode['code']);
				$this->cache->write($data, $encry);
			}else{
				$data = $this->cache->get($encry);
			}
			$this->load->view("home/template",$data);
		}else{
			redirect(base_url());
		}
	}
}